package common

import (
	"fmt"
)

var (
	translate = map[string]string{
		"Please input the UserID.":                                                    "请输入用户代码。",
		"Please input the UserName.":                                                  "请输入用户名称。",
		"Please select the Product.":                                                  "请选择产品。",
		"The twice password is not match.":                                            "两次输入的密码不一致。",
		"Please input the password.":                                                  "请输入密码。",
		"Add User %v finished.":                                                       "增加用户 %v 完成。",
		"Can't modify yourself.":                                                      "不能修改你自己的权限。",
		"Modify User %v finished.":                                                    "修改用户 %v 完成。",
		"Invalid UserID.":                                                             "用户代码无效。",
		"Set User %v Station finished.":                                               "设置用户 %v 站点完成。",
		"Please set the computer first.":                                              "请先设置电脑。",
		"Please select the WorkOrder.":                                                "请选择工单。",
		"WorkOrder process does not include this station.":                            "工单制程不包括此站点。",
		"The products must be tested at the site [%s], it can't be manually scanned.": "产品在站点 [%s] 必须进行测试，不能手工扫描。",
		"System is busy, please wait a moment and try again.":                         "系统忙，请稍候重试。",
		"Please input the Product No.":                                                "请输入产品序号。",
		"Please input the Customer ID.":                                               "请输入客户序号。",
		"Component serial number can not be repeated.":                                "组件序号不能重复。",
		"[ %v ]: [%v] is invalid.":                                                    "组件 [ %v ]: [%v] 无效。",
		"[ %v ]: [%v] didnt complete the process.":                                    "组件 [ %v ]: [%v] 生产流程未完成。",
		"Please get the program that can link the customer ID and print label.":       "请使用打印条码程序来绑定客户序号并打印。",
		"Component serial same as the Product No.":                                    "组件与产品序号相同。",
		"Please input the BOX.":                                                       "请输入包装箱号。",
		"BOX Qty must be a numeric.":                                                  "基准数量必须是不小于零的整数。",
		"BOXID is invalid.":                                                           "包装箱号无效。",
		"The box has been closed.":                                                    "包装箱已关闭。",
		"Please input the fail product.":                                              "请输入不良产品序号。",
		"Type is not REPLACE, the old/new part can't input.":                          "维修类型不是 REPLACE，新/旧组件号码不需要。",
		"Type is REPLACE, input the old/new part No.":                                 "维修类型是 REPLACE，新旧组件号码必须输入。",
		"Repair product: [ %v ] finished.":                                            "维修产品: [ %v ] 完成。",
		"Please input the PO.":                                                        "请输入订单号。",
		"Please input the Source Box.":                                                "请输入来源包装箱号。",
		"Please input the Target Box.":                                                "请输入装入包装箱号。",
		"Please input the Merge Box.":                                                 "请输入合入包装箱号。",
		"Merge Box: From %v To %v finished.":                                          "包装箱合并: 从 %v 到 %v 完成。",
		"Please input the Old SSN.":                                                   "请输入旧条码号。",
		"Please input the New SSN.":                                                   "请输入新条码号。",
		"Can't replace ssn by self.":                                                  "不能与自己更换。",
		"Reaplace SSN: %v --> %v .":                                                   "更换条码: 从 %v 到 %v 。",
		"Query Date is invalid.":                                                      "查询日期不正确。",
		"Query Begin Date is invalid.":                                                "查询开始日期不正确。",
		"Query End Date is invalid.":                                                  "查询结束日期不正确。",
		"Work order / Item can only choose one.":                                      "工单 / 物料 二选其一。",
		"The selected time period is not a valid interval.":                           "查询日期区间不正确。",
		"Date interval can select up to 60 days.":                                     "查询日期区间最多60天。",
		"Date interval can select up to 180 days.":                                    "查询日期区间最多180天。",
		"Date interval can select up to 1000 days.":                                   "查询日期区间最多1000天。",
		"Please input the item number.":                                               "请输入物料号码。",
		"Please select the product type.":                                             "请选择产品类型。",
		"Please input the factory code.":                                              "请输入产品工厂代码。",
		"Pack Qty must be a numberic.":                                                "包装数量必须是一个数字。",
		"Please input the Limit value.":                                               "请输入指标。",
		"Limit value must be a numberic.":                                             "指标必须是一个数值。",
		"Index %d Limit: %s must be a numberic.":                                      "第 %d 个指标: %s 必须是一个数值。",
		"[%sMHz] setting does not match the number of test data.":                     "[%sMHz] 指标设置与测试数据数量不匹配。",
		"[%sMHz] must be a numberic.":                                                 "[%sMHz] 必须是一个数值。",
		"[%sMHz] Index %d must be a numberic.":                                        "[%sMHz] 第 %d 个端口值必须是一个数值。",
		"[%sMHz] test data can not be less than -150.0":                               "[%sMHz] 测试数据不能小于 -150.0",
		"[%sMHz] test data can not be more than 0.0":                                  "[%sMHz] 测试数据不能大于 0.0",
		"[%sMHz] index %d test data can not be less than -150.0":                      "[%sMHz] 第 %d 个测试数据不能小于 -150.0",
		"[%sMHz] index %d test data can not be more than 0.0":                         "[%sMHz] 第 %d 个测试数据不能大于 0.0",
		"%s value can not be less than -150.0":                                        "%s 的值不能小于 -150.0",
		"%s value can not be more than 0.0":                                           "%s 的值不能大于 0.0",
		"Item [%s] Limit didnt set.":                                                  "物料 [%s] 指标未设置。",
		"Set Item: [ %v ] finished.":                                                  "设置物料: [ %v ] 完成。",
		"Please input the Station.":                                                   "请输入站点。",
		"Set Station: [ %v ] finished.":                                               "设置站点: [ %v ] 完成。",
		"Can't get the computer's name, please contact admin.":                        "不能获取电脑名称，请联系系统管理员。",
		"Please select the Line.":                                                     "请选择产线。",
		"Please select the Station.":                                                  "请选择站点。",
		"Set Computer: [ %v ] finished.":                                              "设置电脑: [ %v ] 完成。",
		"Please input the failcode.":                                                  "请输入不良代码。",
		"Set Failure: [ %v ] finished.":                                               "设置不良: [ %v ] 完成。",
		"Please input the Line.":                                                      "请输入产线。",
		"Set Line: [ %v ] finished.":                                                  "设置产线: [ %v ] 完成。",
		"Please select the item.":                                                     "请选择物料。",
		"Please input the part name.":                                                 "请输入组件名称。",
		"The barcode length is Invalid.":                                              "条码长度无效。",
		"The BARCODE is not match LENGTH.":                                            "产品条码与条码长度不匹配。",
		"The part qty must be a numeric.":                                             "组件数量必须是大于零的整数。",
		"Set Items: [ %v ] Part: [ %v ] finished.":                                    "设置物料: [ %v ] 组件: [ %v ] 完成。",
		"Please input the Parameter.":                                                 "请输入打印名称。",
		"Please input the Test Name.":                                                 "请输入测项名称。",
		"Please input the Frequency.":                                                 "请输入频段。",
		"Please input the Ports.":                                                     "请输入端口。",
		"Please input the Specification.":                                             "请输入指标。",
		"Set Items: [ %v ] test info finished.":                                       "设置物料: [ %v ] 测试信息完成。",
		"Please input the routing name.":                                              "请输入制程名称。",
		"Please select the current station.":                                          "请选择当前站。",
		"Please select the next station.":                                             "请选择下一站。",
		"The current station and next station must be different.":                     "当前站和下一站不能相同。",
		"Set Routing: [ %v ] Station: [ %v ] finished.":                               "设置制程: [ %v ] 站点: [ %v ] 完成。",
		"Test times must be a numeric.":                                               "最大测试次数必须是大于零的整数。",
		"Set Station: [ %v ] Testing times finished.":                                 "设置站点: [ %v ] 最大测试次数完成。",
		"Please input the lock No.":                                                   "请输入要进行锁定操作的号码。",
		"System %v: [ %v ] finished.":                                                 "系统 %v: [ %v ] 完成。",
		"Invalid Username or Password.":                                               "无效的用户名或密码。",
		"Old Password is invalid.":                                                    "错误的旧密码。",
		"New Password not match.":                                                     "两次输入的新密码不一致。",
		"New Password must be not empty.":                                             "请输入新密码。",
		"User %v have been changed password.":                                         "用户 %v 修改密码完成。",
		"Please input the WO number.":                                                 "请输入工单号码。",
		"Please input the Version.":                                                   "请输入工单版本。",
		"Qty must be a number.":                                                       "工单数量必须是 1~9999 之间的整数。",
		"Add WorkOrder: [ %v ] finished.":                                             "增加工单: [ %v ] 完成。",
		"Modify WorkOrder: [ %v ] finished.":                                          "修改工单: [ %v ] 完成。",
		"Generate Serial No.: [ %v ] finished.":                                       "工单: [ %v ] 生成序号完成。",
		"Please input %v":                                                             "请输入 %v",
		"Save [ %v ] finished.":                                                       "保存 [%v] 完成。",
		"%v is invalid.":                                                              "%v 无效。",
		"Can't Split Box to itself.":                                                  "不能自己与自己拆分。",
		"Can't Merge Box to itself.":                                                  "不能自己与自己合并。",
		"Qty must be more than zero.":                                                 "数量不能小于零。",
		"Please input the name.":                                                      "请输入名称。",
		"Please input the Repair Action(ENG).":                                        "请输入维修操作(英文)。",
		"Please input the Repair Action(CHN).":                                        "请输入维修操作(中文)。",
		"Please select the Recycle Station.":                                          "请选择回流站点。",
		"Set Repair: [ %s ] finished.":                                                "维修设置 [%s] 完成。",
	}
)

func GetText(lang, trans string, param ...interface{}) string {
	if lang == "en_US" {
		return fmt.Sprintf(trans, param...)
	}
	v, ok := translate[trans]
	if ok {
		return fmt.Sprintf(v, param...)
	}
	return fmt.Sprintf(trans, param...)
}

func GetTextSP(lang string, spRtnData interface{}) string {
	if lang == "en_US" {
		return spRtnData.(SPReturn).EngMsg
	}
	return spRtnData.(SPReturn).ChnMsg
}
